package cn.fuxi2022.core.handler;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 设置MP配置
 *
 * @author Fuxi
 * @date 2022/4/25 19:08
 */
@Configuration
public class MyBatisPlusConfig {
    /**
     * Mybatis Plus 拦截器
     *
     * @return 拦截器
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 1.创建拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 2.添加拦截器（插件）：分页内部拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        // 3.返回拦截器
        return interceptor;
    }
}